﻿// <copyright file="IISEndpointCollection.cs" company="SharpSTS">
// Copyright (c) 2007, 2008 All Right Reserved, http://sharpsts.com/
//
// This source is subject to the Microsoft Permissive License.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Barry Dorrans</author>
// <email>barryd@idunno.org</email>
// <date>2008-06-14</date>
// <summary>Represents the a collection of IISEndpoint configuration elements.</summary>

namespace SharpSTS.Configuration
{
    using System.Configuration;

    /// <summary>
    /// Represents a <see cref="ConfigurationElementCollection"/> of <see cref="InformationEntry"/>s.
    /// </summary>
    /// <example>
    /// &lt;iisEndpointAddresses&gt;
    ///     &lt;clear /&gt;
    ///     &lt;add name="SharpSTS.UserNameAuthSTS" serviceFileName="username.svc" /&gt;
    ///     &lt;add name="SharpSTS.SelfIssuedSamlAuthSTS" serviceFileName="selfissued.svc" /&gt;
    /// &lt;/iisEndpointAddresses&gt;
    /// </example>
    [System.Diagnostics.CodeAnalysis.SuppressMessage(
        "Microsoft.Design",
        "CA1010:CollectionsShouldImplementGenericInterface",
        Justification = "The collection will has a limited use as a ConfigurationElementCollection.")]
    public sealed class IISEndpointCollection : ConfigurationElementCollection
    {
        /// <summary>
        /// Gets the <see cref="IISEndpoint"/> with the specified index.
        /// </summary>
        /// <param name="index">The index of the <see cref="IISEndpoint"/> to get.</param>
        /// <value>The <see cref="IISEndpoint"/> with the specified index</value>
        public IISEndpoint this[int index]
        {
            get
            {
                return (IISEndpoint)BaseGet(index);
            }
        }

        /// <summary>
        /// Creates a new <see cref="IISEndpoint"/>.
        /// </summary>
        /// <returns>
        /// A new <see cref="IISEndpoint"/>.
        /// </returns>
        protected override ConfigurationElement CreateNewElement()
        {
            return new IISEndpoint();
        }

        /// <summary>
        /// Gets the element key for a specified configuration element when overridden in a derived class.
        /// </summary>
        /// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement"/> to return the key for.</param>
        /// <returns>
        /// An <see cref="T:System.Object"/> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement"/>.
        /// </returns>
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((IISEndpoint)element).Name;
        }
    }
}
